package com.emin.platform.subjectcenter.service.impl;

import com.emin.base.service.UndeleteableServiceImpl;
import com.emin.platform.subjectcenter.common.response.ResponseBack;
import com.emin.platform.subjectcenter.entity.Industory;
import com.emin.platform.subjectcenter.service.IndustoryService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;

import java.util.List;

/** 行业服务类
 * @author Jack
 * @version V1.0
 * @Title:
 * @Description: 行业服务类
 * @date 2017/10/25 17:09
 */
@Service
public class IndustoryServiceImpl extends UndeleteableServiceImpl<Industory> implements
        IndustoryService {
    @Override
    public ResponseBack<JSONArray> getIndustorys() {
        try {
            List<Industory> resultList = this.findAllByStatus(1);
            JSONArray result = new JSONArray();
            if (null != resultList && resultList.size() > 0) {
                for (Industory industory : resultList) {
                    JSONObject json = new JSONObject();
                    json.put("id", industory.getId());
                    json.put("name", industory.getName());
                    result.add(json);
                }
            }
            return ResponseBack.success(result);
        } catch (Exception e) {
            throw e;
        }
    }
}
